//
//  BankInfoViewController.m
//  YiBaoStore
//
//  Created by 吕清毅 on 2018/11/25.
//  Copyright © 2018年 小河. All rights reserved.
//

#import "BankInfoViewController.h"
#import "BankListViewController.h"
#import "ChangeBankCardControllerViewController.h"

@interface BankInfoViewController ()

@property (nonatomic,strong)ChangeBankCardControllerViewController *changeVC;
@end

@implementation BankInfoViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    self.bgNavView.hidden = YES;
    [self setNaviWith:@"银行信息"];
    //[self setMainView];
}

- (void)viewWillAppear:(BOOL)animated
{
    [super viewWillAppear:animated];
    [self getHttpData];
}

- (void)getHttpData
{
    [[HttpRequest currentHttpRequest]postPath:GetBankInfo_API params:nil resultBlock:^(id Data, MsgModel *msgModel) {
        [self setMainViewWith:Data];
    }];
}

- (void)setMainViewWith:(NSDictionary *)data
{
    UIView *bankView = [UIView new];
    bankView.frame = CGRectMake(15, TopBarHeight+TopStatusHeight+15, SCREENWIDTH-30, 65);
    bankView.backgroundColor = goldColor;
    bankView.layer.cornerRadius = 8;
    [self.view addSubview:bankView];
    
    UIImageView *leftIV = [UIImageView new];
    leftIV.frame = CGRectMake(17, 13, 39, 39);
    //pleaseholder bankBack
    leftIV.image = [UIImage imageNamed:@"gongBank"];
    [bankView addSubview:leftIV];
    
    UILabel *bankLab = [UILabel new];
    bankLab.frame = CGRectMake(leftIV.right+10, 13, 120, 22);
    bankLab.textColor = TotalWhite;
    bankLab.font = FontSemiboldSize(16);
    bankLab.attributedText = [TTKUtil getAtttributeStringWithLineSpace:0 kern:1 and:[NSString stringWithFormat:@"%@",data[@"bankCardOwnerName"]]];
    [bankView addSubview:bankLab];
    
    UILabel *idCardLab = [UILabel new];
    idCardLab.frame = CGRectMake(bankLab.left, bankLab.bottom+10, 130, 14);
    idCardLab.textColor = TotalWhite;
    idCardLab.font = FontSemiboldSize(10);
    idCardLab.attributedText = [TTKUtil getAtttributeStringWithLineSpace:0 kern:1 and:[NSString stringWithFormat:@"%@",data[@"bankCardNumber"]]];
    [bankView addSubview:idCardLab];
    
    UIView *changeView = [UIView new];
    changeView.frame = CGRectMake(bankView.left, bankView.bottom+25, SCREENWIDTH-30, 50);
    changeView.layer.cornerRadius = 8;
    changeView.layer.borderWidth = 1;
    changeView.layer.borderColor = UIColorFromHex(0xDCDCDC).CGColor;
    [self.view addSubview:changeView];
    
    UIImageView *changeIV = [UIImageView new];
    changeIV.frame = CGRectMake(22, 15, 20, 20);
    changeIV.image = [UIImage imageNamed:@"changeCard"];
    [changeView addSubview:changeIV];
    
    UILabel *changeLab = [UILabel new];
    changeLab.frame = CGRectMake(changeIV.right+24, 16, 75, 18);
    changeLab.textColor = titleColor;
    changeLab.font = FontWithSize(14);
    changeLab.text = @"换绑银行卡";
    [changeView addSubview:changeLab];
    
    UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(changeBank)];
    [changeView addGestureRecognizer:tap];
    
    float padd = (SCREENWIDTH-93)/2;
    UIImageView *quesIV = [UIImageView new];
    quesIV.frame = CGRectMake(padd, SCREENHEIGHT-BottomHeight-30-16, 16, 16);
    quesIV.image = [UIImage imageNamed:@"question"];
    [self.view addSubview:quesIV];
    
    UILabel *quesLab = [UILabel new];
    quesLab.frame = CGRectMake(quesIV.right+5, quesIV.top+2, 72, 12);
    quesLab.textColor = UIColorFromHex(0x3CB1FA);
    quesLab.font = FontWithSize(12);
    quesLab.text = @"查看支持银行";
    [self.view addSubview:quesLab];
    
    UIButton *quesBtn = [UIButton buttonWithType:UIButtonTypeCustom];
    quesBtn.frame = CGRectMake(quesIV.left-5, quesIV.top-5, 105, 26);
    [quesBtn addTarget:self action:@selector(questionList:) forControlEvents:UIControlEventTouchUpInside];
    [self.view addSubview:quesBtn];
}

#pragma mark  -- 换绑
- (void)changeBank
{
    self.changeVC = [[ChangeBankCardControllerViewController alloc]init];
    [self.view addSubview:self.changeVC.view];
    //[[UIApplication sharedApplication].windows[0] addSubview:self.pickVC.view];
    self.changeVC.view.frame = CGRectMake(0, 0, SCREENWIDTH, SCREENHEIGHT);
}

#pragma marl -- 查看支持的银行
- (void)questionList:(UIButton *)btn
{
    BankListViewController *bankList = [BankListViewController new];
    [self.navigationController pushViewController:bankList animated:YES];
}
@end
